Numpy Datatype: Enable np.dtype() type conversions - #1856
Conversation
3d996b7 to
a4c6bf9
Compare
| try | ||
| { | ||
| create_dtype = numpy.attr("dtype"); | ||
| } | ||
| catch (std::exception const &e) |
There was a problem hiding this comment.
Maybe check if it has the attribute and then throw? Avoids one catch
There was a problem hiding this comment.
I have removed those try-catch blocks which should only throw if the numpy interfaces change. This leaves those two blocks that check if numpy is installed and for any errors when calling numpy.dtype() with user-supplied objects.
752d517 to
6c346d0
Compare
6c346d0 to
b164b88
Compare
b164b88 to
3f96ee9
Compare
Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>
3f96ee9 to
037e8a2
Compare
| self.assertEqual(dc128.dtype, "complex128") | ||
| if file_ending not in ["bp", "bp4", "bp5"]: | ||
| self.assertTrue(dc256.dtype == np.dtype("clongdouble")) | ||
| self.assertTrue(dc256.dtype == "clongdouble") |
Check failure
Code scanning / CodeQL
Potentially uninitialized local variable Error test
| self.assertTrue(ms["uint64"][SCALAR].constant) | ||
| self.assertTrue(ms["double"][SCALAR].constant) | ||
|
|
||
| self.assertTrue(ms["int16"][SCALAR].load_chunk(o, e).dtype == "int16") |
Check notice
Code scanning / CodeQL
Imprecise assert Note test
| self.assertTrue(ms["double"][SCALAR].constant) | ||
|
|
||
| self.assertTrue(ms["int16"][SCALAR].load_chunk(o, e).dtype == "int16") | ||
| self.assertTrue(ms["int32"][SCALAR].load_chunk(o, e).dtype == "int32") |
Check notice
Code scanning / CodeQL
Imprecise assert Note test
|
|
||
| self.assertTrue(ms["int16"][SCALAR].load_chunk(o, e).dtype == "int16") | ||
| self.assertTrue(ms["int32"][SCALAR].load_chunk(o, e).dtype == "int32") | ||
| self.assertTrue(ms["int64"][SCALAR].load_chunk(o, e).dtype == "int64") |
Check notice
Code scanning / CodeQL
Imprecise assert Note test
| self.assertTrue(ms["int16"][SCALAR].load_chunk(o, e).dtype == "int16") | ||
| self.assertTrue(ms["int32"][SCALAR].load_chunk(o, e).dtype == "int32") | ||
| self.assertTrue(ms["int64"][SCALAR].load_chunk(o, e).dtype == "int64") | ||
| self.assertTrue(ms["uint16"][SCALAR].load_chunk(o, e).dtype == "uint16") |
Check notice
Code scanning / CodeQL
Imprecise assert Note test
| self.assertTrue(ms["int32"][SCALAR].load_chunk(o, e).dtype == "int32") | ||
| self.assertTrue(ms["int64"][SCALAR].load_chunk(o, e).dtype == "int64") | ||
| self.assertTrue(ms["uint16"][SCALAR].load_chunk(o, e).dtype == "uint16") | ||
| self.assertTrue(ms["uint32"][SCALAR].load_chunk(o, e).dtype == "uint32") |
Check notice
Code scanning / CodeQL
Imprecise assert Note test
| self.assertTrue(ms["int64"][SCALAR].load_chunk(o, e).dtype == "int64") | ||
| self.assertTrue(ms["uint16"][SCALAR].load_chunk(o, e).dtype == "uint16") | ||
| self.assertTrue(ms["uint32"][SCALAR].load_chunk(o, e).dtype == "uint32") | ||
| self.assertTrue(ms["uint64"][SCALAR].load_chunk(o, e).dtype == "uint64") |
Check notice
Code scanning / CodeQL
Imprecise assert Note test
| self.assertTrue(ms["uint16"][SCALAR].load_chunk(o, e).dtype == "uint16") | ||
| self.assertTrue(ms["uint32"][SCALAR].load_chunk(o, e).dtype == "uint32") | ||
| self.assertTrue(ms["uint64"][SCALAR].load_chunk(o, e).dtype == "uint64") | ||
| self.assertTrue(ms["single"][SCALAR].load_chunk(o, e).dtype == "single") |
Check notice
Code scanning / CodeQL
Imprecise assert Note test
| self.assertTrue(ms["uint32"][SCALAR].load_chunk(o, e).dtype == "uint32") | ||
| self.assertTrue(ms["uint64"][SCALAR].load_chunk(o, e).dtype == "uint64") | ||
| self.assertTrue(ms["single"][SCALAR].load_chunk(o, e).dtype == "single") | ||
| self.assertTrue(ms["double"][SCALAR].load_chunk(o, e).dtype == "double") |
Check notice
Code scanning / CodeQL
Imprecise assert Note test
| self.assertEqual(dc128.dtype, "complex128") | ||
| if file_ending not in ["bp", "bp4", "bp5"]: | ||
| self.assertTrue(dc256.dtype == np.dtype("clongdouble")) | ||
| self.assertTrue(dc256.dtype == "clongdouble") |
Check notice
Code scanning / CodeQL
Imprecise assert Note test
ax3l
left a comment
There was a problem hiding this comment.
LGTM - looks bw compatible. Please fix the one CodeQL error it brought up and then ready :)
This makes it possible to use things like
np.int_or"double"in theDatasetconstructor, which currently has to be written asnp.dtype(np.int_)andnp.dtype("double"). Check also examples and tests.Affects
Datatype()constructor as well asRecordComponent.make_empty().Future: Derive Dataset definition from Numpy array directly